package easy;

public class Solution_1629 {
    public char slowestKey(int[] releaseTimes, String keysPressed) {
        int max = 0;
        char maxChar = ' ';
        int pre = 0;
        for (int i = 0; i < releaseTimes.length; i++) {
            int temp = releaseTimes[i] - pre;
            if (temp == max) {
                if (maxChar == ' ' || keysPressed.charAt(i) > maxChar) {
                    maxChar = keysPressed.charAt(i);
                }
            } else if (temp > max) {
                max = temp;
                maxChar = keysPressed.charAt(i);
            }
            pre = releaseTimes[i];
        }
        return maxChar;
    }

    public static void main(String[] args) {
        Solution_1629 model = new Solution_1629();
        System.out.println(model.slowestKey(new int[]{9, 29, 49, 50}, "cbcd"));
        System.out.println(model.slowestKey(new int[]{12, 23, 36, 46, 62}, "spuda"));
    }
}
